#!/usr/bin/env bash

# http://jdk.java.net/
echo "下载 jdk8u41-src.zip"
if [ ! -f resources/jdk8u41-src.zip ]; then
  wget https://download.java.net/openjdk/jdk8u41/ri/openjdk-8u41-src-b04-14_jan_2020.zip -O resources/jdk8u41-src.zip
fi

echo "下载 jdk7u75-bin.zip"
if [ ! -f resources/jdk7u75-bin.tar.gz ]; then
  wget https://download.java.net/openjdk/jdk7u75/ri/openjdk-7u75-b13-linux-x64-18_dec_2014.tar.gz -O resources/jdk7u75-bin.tar.gz
fi

echo "启动虚拟机"
vagrant up

echo "虚拟机设置并安装软件"
# 加&符号表示后台子进程执行，三台虚拟机并行安装
#vagrant ssh server -c "sudo setup" &
vagrant ssh server -c "sudo setup"

# 等待所有子进程执行完毕
# wait

echo -e "耗时: $SECONDS s"
